<?php
function itx_get_option($opt,$i=false){
    if ($ret=get_option('itx_'.$opt)){
        if(!$i) return $ret;
        elseif (is_object($ret)&&isset($ret->$i)) return $ret->$i;
        elseif (isset($ret[$i])) return $ret[$i];
        else return itx_default_option($opt,$i);
    } else return itx_default_option($opt,$i);
}

function itx_update_option($opt,$value,$i=false){
    if ($i) {
	$fval=get_option('itx_'.$opt);
	$fval[$i]=$value;
	$value=$fval;
    }
    update_option('itx_'.$opt,$value);
}

function itx_default_option($opt,$i=false){
    switch ($opt){
    case'header':
        $ret=array(
            'head_type'=>0,
			'image'=>'',
			'repeat'=>'no-repeat',
			'position'=>'',
			'scope'=>0,
            'color'=>'#ffffff',
            'hover_color'=>'#aaffff',
            'span_color'=>'#eeffff',
            'bgcolor'=>'transparent',
            'text_align'=>'center',
            'font_size'=>'3.5em',
            'span_font_size'=>'1.8em',
        );
        break;
    case'bg':
        $ret=array(
			'image'=> get_bloginfo('template_directory').'/images/albiziabg.jpg',
            'attachment'=>'scroll',
            'repeat'=>'no-repeat',
            'bgcolor'=>'',
            'v_align'=>'top',
            'h_align'=>'center',
            'resize'=>'100',
        );
        break;
   case'links':
        $ret=array(
            'rss'=>get_bloginfo('rss2_url'),
            'crss'=>get_bloginfo('comments_rss2_url'),
            'twitter'=>'itx_',
            'facebook'=>'pages/Albizia-Theme/129010583790562',
        );
         break;
    case'front':
        $ret=array(
            'type'=>'fe',
            'column'=>2,
            'featuredlim'=>70,
            'excerptlim'=>20,
            'featuredx'=>300,
            'featuredy'=>200,
			'fnotimg'=>'',
            'thumbx'=>150,
            'thumby'=>100,
			'notimg'=>'',
            'catch'=>1,
			'not'=>1
        );
         break;
    case'menu':
        $ret=array(
            'wp_menu'=>1,
            'top_home'=>'Home',
            'top_align'=>'right',
            'top_depth'=>0,
            'top_show'=>'page',
            'top_margin'=>180,
            'home'=>'Home',
            'depth'=>0,
            'cat_inc'=>array(),
            'cat_sortby'=>'name',
            'cat_order'=>'ASC',
            'page_inc'=>array(),
            'page_sortby'=>'post_title',
            'page_order'=>'ASC',
            'show'=>'cat'
        );
        break;
    case'vars':
        $ret=(object)array(
            'data'=>'<div id="footerright"><strong><a href="http://albizia.itx.web.id/">Albizia Theme</a></strong> designed by <a href="http://itx.web.id/">itx</a></div></div></div></div>',
        );
        break;
    case'layout':
        $ret=array(
            'column'=>3,
            'wrap'=>'1000',
            'wrapping'=>'flex',
            'sidebar1'=>'300',
            'sidebar2'=>'150',
            'sidebarunit'=>'px',
			'style'=>0,
            'innertop'=>2,
            'innerbottom'=>2,
            'footer'=>4,
        );
        break;
    case'misc':
        $ret=array(
            'favicon'=> get_bloginfo('template_directory').'/images/favicon.ico'
        );
        break;
    }
        
    if($i) {
        if (is_object($ret)) return $ret->$i;
        else return $ret[$i];
    }
    else return $ret;
}

function itx_rss(){
    $l=get_option('itx_links');
    if ($l['rss']){ echo $l['rss'];}
    else {bloginfo('rss2_url');}
}

function itx_crss(){
    $l=get_option('itx_links');
    if ($l['crss']){ echo $l['crss'];}
    else {bloginfo('comments_rss2_url');}
}
?>